[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 setbuf()                Control Stream Buffering

 #include   <stdio.h>

 void       setbuf(stream,buffer);
 FILE       *stream;                     Pointer to file structure
 char       *buffer;                     User-allocated buffer

    setbuf() allows the user to control buffering by assigning 'stream'
    to a specified 'buffer' instead of to a buffer automatically
    allocated for the task.  'stream' must refer to an open file.  The
    stream is fully buffered unless 'buffer' is NULL, in which case the
    stream is unbuffered.  'buffer' must point to a character array
    BUFSIZ bytes long. (BUFSIZ is defined in <stdio.h>).

       Returns:     Nothing

         Notes:     'stderr' and 'stdaux' are unbuffered by default.
                    They can be assigned buffers with setbuf().

   -------------------------------- Example ---------------------------------

    The following statements open two files and assign a user-specified
    buffer to one.

           #include <stdio.h>

           char buf[BUFSIZ];
           FILE *stream1, *stream2;

           main()
           {
               if((stream1 = fopen("data1","w+")) != NULL &&
                  (stream2 = fopen("data2","w+")) != NULL)  {
                       setbuf(stream1,buf);
               }
           }


See Also: fflush() fopen() fclose() setvbuf()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson